#include "misc.h"

#include <Windows.h>

#pragma warning(disable:4996)

TCHAR* get_config_str(TCHAR* section, TCHAR* key) {
	TCHAR cfgPath[MAX_PATH] = { 0 };
	GetModuleFileName(NULL, cfgPath, MAX_PATH);
	TCHAR* fnd = _tcsrchr(cfgPath, '\\');
	fnd[1] = L'\0';
	_tcscat(cfgPath, _T("avo_config.ini"));
	
	static TCHAR config_v[256] = { 0 };
	memset(config_v, 0, sizeof(config_v));
	int ret = GetPrivateProfileString(section, key, 0, config_v, sizeof(config_v), cfgPath);

	/*GetPrivateProfileStringW(
		_In_opt_ LPCWSTR lpAppName,
		_In_opt_ LPCWSTR lpKeyName,
		_In_opt_ LPCWSTR lpDefault,
		_Out_writes_to_opt_(nSize, return +1) LPWSTR lpReturnedString,
		_In_     DWORD nSize,
		_In_opt_ LPCWSTR lpFileName
	);*/

	if (ret > 0) {
		return config_v;
	}
	return 0;
}